package com.tancire.net.service.impl;

import java.util.List;
import javax.annotation.Resource;

import cn.hutool.core.util.IdUtil;
import com.tancire.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.tancire.net.mapper.ShopGoodsCategoryMapper;
import com.tancire.net.domain.ShopGoodsCategory;
import com.tancire.net.service.IShopGoodsCategoryService;

/**
 * 商品分类Service业务层处理
 *
 * @author chenchao
 * @date 2023-11-20
 */
@Service
public class ShopGoodsCategoryServiceImpl implements IShopGoodsCategoryService {
    @Resource
    private ShopGoodsCategoryMapper shopGoodsCategoryMapper;

    /**
     * 查询商品分类
     *
     * @param id 商品分类主键
     * @return 商品分类
     */
    @Override
    public ShopGoodsCategory selectShopGoodsCategoryById(Long id) {
        return shopGoodsCategoryMapper.selectShopGoodsCategoryById(id);
    }

    /**
     * 查询商品分类列表
     *
     * @param shopGoodsCategory 商品分类
     * @return 商品分类
     */
    @Override
    public List<ShopGoodsCategory> selectShopGoodsCategoryList(ShopGoodsCategory shopGoodsCategory) {
        return shopGoodsCategoryMapper.selectShopGoodsCategoryList(shopGoodsCategory);
    }

    /**
     * 新增商品分类
     *
     * @param shopGoodsCategory 商品分类
     * @return 结果
     */
    @Override
    public int insertShopGoodsCategory(ShopGoodsCategory shopGoodsCategory) {
        shopGoodsCategory.setCreateTime(DateUtils.getNowDate());
        shopGoodsCategory.setId(IdUtil.getSnowflakeNextId());
        return shopGoodsCategoryMapper.insertShopGoodsCategory(shopGoodsCategory);
    }

    /**
     * 修改商品分类
     *
     * @param shopGoodsCategory 商品分类
     * @return 结果
     */
    @Override
    public int updateShopGoodsCategory(ShopGoodsCategory shopGoodsCategory) {
        shopGoodsCategory.setUpdateTime(DateUtils.getNowDate());
        return shopGoodsCategoryMapper.updateShopGoodsCategory(shopGoodsCategory);
    }

    /**
     * 批量删除商品分类
     *
     * @param ids 需要删除的商品分类主键
     * @return 结果
     */
    @Override
    public int deleteShopGoodsCategoryByIds(Long[] ids) {
        return shopGoodsCategoryMapper.deleteShopGoodsCategoryByIds(ids);
    }

    /**
     * 删除商品分类信息
     *
     * @param id 商品分类主键
     * @return 结果
     */
    @Override
    public int deleteShopGoodsCategoryById(Long id) {
        return shopGoodsCategoryMapper.deleteShopGoodsCategoryById(id);
    }
}
